package com.example.wangzh.mytest;


import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.example.wangzh.mytest.databinding.ActivityDispatchEventTestBinding;
import com.example.wangzh.mytest.utils.LogUtils;

@SuppressLint("ClickableViewAccessibility,NonConstantResourceId")
public class DispatchEventTestActivity extends AppCompatActivity {
    public final String TAG = getClass().getSimpleName();
    @SuppressWarnings("FieldCanBeLocal")
    private ActivityDispatchEventTestBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivityDispatchEventTestBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        binding.dptlnl.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                boolean result = true;
                Log.i("view", "onTouch>>>" + result);
                return result;
            }
        });
        binding.txtTest.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                boolean result = false;
                Log.i("view", "txt_testOnTouch>>>" + result);
                return result;
            }
        });
        binding.txtTestTouch.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    LogUtils.i(TAG, "action down");
                    return true;
                } else if (event.getAction() == MotionEvent.ACTION_UP) {
                    LogUtils.i(TAG, "action up");
                    return false;
                }
                return true;
            }
        });
    }
}
